package com.chang.bootplus.controller;


import com.chang.bootplus.base.annotation.PublicVisit;
import com.chang.bootplus.base.utils.ApiResponse;
import com.chang.bootplus.po.ProductCatesIdPO;
import com.chang.bootplus.po.ProductCatesPO;
import com.chang.bootplus.po.ProductIdPO;
import com.chang.bootplus.service.ProductCatesService;
import com.chang.bootplus.vo.ProductCatesVO;
import com.chang.bootplus.vo.ProductVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ning
 * @since 2022-01-25
 */
@RestController
@RequestMapping("/product-cates")
@Api(tags = {"商品分类信息"})
@CrossOrigin(origins = "*")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ProductCatesController {

    final ProductCatesService productCatesService;

    // 查询分类信息
    @PostMapping("listProductCategory")
    @ApiOperation(httpMethod = "POST", value = "查询分类信息")
    @PublicVisit
    public ApiResponse<ProductCatesVO> listProductCategory(@RequestBody ProductCatesIdPO po){
        return productCatesService.listProductCategory(po);
    }

    // 增加分类信息
    @PostMapping("addProductCategory")
    @ApiOperation(httpMethod = "POST", value = "增加分类信息")
    public ApiResponse<Void> addProductCategory(@RequestBody ProductCatesPO po){
        return productCatesService.addProductCategory(po);
    }

}

